package use.io;

import java.io.*;

public class BitOperation {
    public static void copyFile(String src, String dist) throws IOException {
        FileInputStream in = new FileInputStream(src);
        FileOutputStream out = new FileOutputStream(dist);
        byte[] buffer = new byte[20 * 1024];
        int cnt;
        //read返回实际操作个数,返回-1说明读到文件尾
        while ((cnt = in.read(buffer, 0, buffer.length)) != -1) {
            out.write(buffer, 0, cnt);
        }

        in.close();
        out.close();
    }

    public static void encodeAndDecode() throws UnsupportedEncodingException {
        String str1 = "中文";
        byte[] bytes = str1.getBytes("UTF-8");
        byte[] bytes1 = str1.getBytes();
        System.out.println(bytes);
        System.out.println(bytes1);
    }
    public static void main(String[] args) throws IOException {
        encodeAndDecode();
    }
}
